// 
// jstcky
// 
// Copyright (c) 2009 Ryan Yonzon (http://ryan.rawswift.com/)
// 
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// 
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

var _c = 0; // public counter

	// constructor	
	function jStcky(_obj) {
		this._obj_arr = Array(); // init object storage
		this.wrapper = _obj.wrapper; // init element (div) menu wrapper 
		this.menu = _obj.menu; // init element (div) menu holder
		
		// set html and body style
		$("html").css({
			"margin": "0px",
			"overflow" : "hidden",
			"height" : "100%"
		});

		$("body").css({
			"margin": "0px",
			"overflow" : "auto",
			"height" : "100%"
		});

		// create the (div) element wrapper
		$("<div />").attr("id", this.wrapper).appendTo("body");
		$("<div />").attr("class", this.menu).appendTo("#" + this.wrapper);
		
		// set wrapper style
		$("#" + this.wrapper).css({
				"overflow" : "hidden",
				"height" : "30px",
				"width" : "100%",
				"position" : "absolute",
				"bottom" : "0px"
		});
		
		// set menu style
		$("." + this.menu).css({
				"bottom" : "0px",
				"height" : "30px",
				"margin-left" : "auto",
				"margin-right" : "auto",
				"width" : "900px",
				"background-color" : "#EEEEEE",
				"border" : "#CCCCCC solid 1px"
		});
	}

	// method addItem
	jStcky.prototype.addItem = function(_item) {
		this._obj_arr[_c] = _item; // save object
		_c++; // increment counter
	}
	
	// method showItem
	jStcky.prototype.showItem = function() {
	
		$("<ul />").attr("class", 'menu_list').css({"margin-top" : "5px", "list-style" : "none"}).appendTo("." + this.menu);
	
		for(var _o in this._obj_arr) { // iterate through object storage
			var _prop = Array(); // initialize temporary property storage
			for(var _v in this._obj_arr[_o]) { // iterate through objects
				_obj = this._obj_arr[_o]; // get individual 
				//alert(_v + ' : ' + _obj[_v]);
					switch(_v) {
						case 'title':
							_prop['title'] = _obj[_v]; // title 
							break;
						case 'link':
							_prop['link'] = _obj[_v]; // link
							break;
						case 'image':
							_prop['image'] = _obj[_v]; // image
							break;
						default:
							break;
					}
			} // end for loop
			$(".menu_list").append('<li><a href="' + _prop['link'] + '">' + _prop['title'] + '</a></li>');				
		} // end for loop

		$("li").css({"display" : "inline", "margin-left" : "10px"});		
		
	} // end show method
